<template>
  <div id="complete" class="flex grow column">
    <div class="box">
      <div class="top-title">
        <div class="top-l fl">财经资讯</div>
        <div class="top-r fr">
          <div class="tab-item">
            <router-link to="/recommend">推荐</router-link>
          </div>
          <span class="line"></span>
          <div class="tab-item">
            <router-link to="/calendar">财经日历</router-link>
          </div>
          <span class="line"></span>
          <div class="tab-item">
            <router-link to="/center">新股中心</router-link>
          </div>
        </div>
      </div>
    </div>
    <keep-alive>
      <router-view></router-view>
    </keep-alive>
    <layer
      :title="layerTitle"
      v-show="layerVisible"
      @close="layerVisible = false"
    />
  </div>
</template>
<script>
import hub, { SERVICE_EXCEPTION, TIMEOUT } from "./script/hub";
import layer from "./components/layer.vue";

export default {
  components: { layer },
  data() {
    return {
      layerTitle: "网络连接错误",
      layerVisible: false,
    };
  },
  mounted() {
    hub.on(SERVICE_EXCEPTION, () => {
      this.layerVisible = true;
      this.layerTitle = "服务器出现异常";
    });
    hub.on(TIMEOUT, () => {
      this.layerVisible = true;
      this.layerTitle = "网络连接超时";
    });
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
#complete {
  width: 100%;
  background: #090910;
  .box {
    width: 100%;
    background: #27282e;
    height: 66px;
    margin-bottom: 20px;
  }
  .top-title {
    margin: 0 auto;
    width: 1200px;

    .top-l {
      width: 140px;
      height: 31px;
      font-size: 32px;
      font-weight: 400;
      color: rgba(188, 191, 196, 1);
      line-height: 66px;
    }
    .top-r {
      width: 350px;
      .line {
        float: left;
        box-sizing: border-box;
        border-left: 1px solid #25262a;
        border-right: 1px solid #434448;
        margin: 19px 16px;
        height: 29px;
        width: 1px;
      }
      .tab-item {
        float: left;
        margin-top: 19px;
        background: rgba(67, 68, 72, 1);
        font-size: 18px;
        font-weight: 400;
        line-height: 29px;
        text-align: center;
        a {
          display: inline-block;
          width: 94px;
          height: 29px;
          color: rgba(188, 191, 196, 1);
        }
        .active {
          color: #ffffff;
          background: #2d5bcd;
        }
      }
    }
  }
}
</style>
